package com.wz.jiangsu.main.huiwenshu;

import org.assertj.core.util.Lists;
import retrofit2.http.GET;

import java.util.ArrayList;
import java.util.List;

public class TestAvg {
    public static void main(String[] args) {
        ArrayList<Integer> list = Lists.newArrayList(3, 4, 1, 22, 11, 53, 223, 234, 23);
        List<List<Integer>> lists = new ArrayList<>();

        lists = getNewArraylists(list,7);
        System.out.println(lists);


    }

    private static List<List<Integer>> getNewArraylists(ArrayList<Integer> list,int group) {
        List<List<Integer>> lists = new ArrayList<>();
        int size = list.size();
        int base = size / group;
        int remain = size % group;
        int start = 0 ;
        for (int i = 0; i < group; i++) {
            int end = start + base + (i < remain ? 1 : 0);
            List<Integer> list1 = list.subList(start, end);
            lists.add(list1);
            start = end;
        }

        return lists;
    }
}
